package jsonpath;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import java.io.IOException;
import java.util.Map;
import net.minidev.json.JSONObject;

public class TestJsonPath {

    public static void main(String[] args) throws IOException {
        String json = "{\"tableInfos\":[{\"ip\":\"192.168.11.104\",\"port\":\"1521\",\"type\":\"ORACLE\",\"schema\":\"SCOTT\",\"tableMetaDes\":[{\"tableName\":\"HR\",\"columnList\":[\"ID\",\"NAME\",\"\\\"addr\\\"\"]},{\"tableName\":\"HR2\",\"columnList\":[\"ID2\",\"NAME2\",\"\\\"addr2\\\"\"]}]},{\"ip\":\"192.168.14.165\",\"port\":\"1521\",\"type\":\"ORACLE\",\"schema\":\"TTT\",\"tableMetaDes\":[{\"tableName\":\"HR\",\"columnList\":[\"ID\",\"NAME\",\"\\\"addr\\\"\"]},{\"tableName\":\"HR2\",\"columnList\":[\"ID2\",\"NAME2\",\"\\\"addr2\\\"\"]}]}]}";

        ObjectMapper objectMapper = new ObjectMapper();
        Map m = objectMapper.readValue(json, Map.class);

        System.out.println(m.size());

        m.keySet().stream().forEach(k -> System.out.println("key==>" + k + ",value:" + m.get(k)));
    }
}
